home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20031118-20041115
/
000387_fdc@columbia.edu_Sun Sep 5 16:18:49 2004.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
4KB
Path: newsmaster.cc.columbia.edu!not-for-mail
From: Frank da Cruz <fdc@columbia.edu>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: GPS NMEA time reader
Date: 5 Sep 2004 20:17:58 GMT
Organization: Columbia University
Lines: 100
Message-ID: <slrncjmt3m.4t1.fdc@sesame.cc.columbia.edu>
References: <ch4m71$koi$2@blue.rahul.net> <slrncjbtvl.iqr.fdc@sesame.cc.columbia.edu> <78889$413b33a0$44a75e7a$24367@msgid.meganewsservers.com>
Reply-To: fdc@columbia.edu
NNTP-Posting-Host: sesame.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1094415478 1830 128.59.59.56 (5 Sep 2004 20:17:58 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 5 Sep 2004 20:17:58 GMT
User-Agent: slrn/0.9.8.0 (SunOS)
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15158
On 2004-09-05, Robert Bonomi <bonomi@host122.r-bonomi.com> wrote:
: In article <slrncjbtvl.iqr.fdc@sesame.cc.columbia.edu>,
: Frank da Cruz <fdc@columbia.edu> wrote:
:>...
:>: This is from 010904 September 1, 2004, at 13:40:58 GMT
:>: Once satellite lock is found, the position appears
:>: $GPRMC,134058,A,3850.1234,N,12230.5678,W,0.0,71.4,010904,15.0,E,A*0D
:>: ------ ------
:>: Before satellite lock is found, there is no position, and no time.
:>: The ",V," indicates that the fix is no good.
:>: $GPRMC,,V,,,,,,,010904,15.0,E,N*00
:>:
:>You didn't say how to decode these, but if a time is in there, Kermit
:>string and date/time functions can deal with it. As to actually setting
:>the system time, you'll need to invoke an external program (RUN or RUN START)
:>with appropriate command line options and privileges.
:
:
: The 'decoding' is obvious. <grin>
: The 2nd field is HHMMSS, the 11th field is DDMMYY
: (note: decoding derived from his supplied data, with the plain-text
: explanation line that precedes it, and his underlining of
: fields 2 and 11.)
:
Hey, no making fun of me! OK, fine, here is a more helpful response.
The record is a comma-seperated list. How to extract the date and time?
.\%a = $GPRMC,134058,A,3850.1234,N,12230.5678,W,0.0,71.4,010904,15.0,E,A*0D
echo \fsplit(\%a,&a,{,},$.*)
This splits the string items into the array \&a[], using comma as the item
separator, and treating dollar sign, period, and asterisk as data characters.
Here's the result:
show array a
\&a[]: Dimension = 13
0. 13
1. $GPRMC
2. 134058
3. A
4. 3850.1234
5. N
6. 12230.5678
7. W
8. 0.0
9. 71.4
10. 010904
11. 15.0
12. E
13. A*0D
Now \&a[10] is the date and \&a[2] is the time. The date format used in
the message is totally ambiguous (yes, *we* know it's ddmmyy but...) so we
have to convert it to something parsable:
.d := \&a[10] ; Date (notational convenience)
.time := 20\s(d[5:2])\s(d[3:2])\s(d[1:2])_\&a[2]
date \m(time)
20040901 13:40:58
But it's GMT not local time so we must convert; easy:
date \m(time)GMT
20040901 09:40:58
Programmatically:
.time := \fcvtdate(\m(time)GMT)
echo \m(date)
20040901 09:40:58
Now to program this we have to allow for the degenerate form and we might
also have to convert the result into some other format. Assuming we have
read a satellite record into the variable \%a:
void \fsplit(\%a,&a,{,},$.*)
if ( def \&a[2] && def \&a[10] ) {
.t := \&a[2]
.time := \fcvtdate(20\s(d[5:2])\s(d[3:2])\s(d[1:2])_\&a[2]GMT)
echo "Setting time to \m(time)..."
run xxx \m(time) ; external command to set system time
} else {
end 1 "Date-time not not set"
}
The external time-setting command might require a different operand format.
\vcvtdate() accepts an optional second argument to specify the format of
the result:
n1 = 1: yyyy-mmm-dd hh:mm:ss (mmm = English 3-letter month abbreviation)
n1 = 2: dd-mmm-yyyy hh:mm:ss (ditto)
n1 = 3: yyyymmddhhmmss (all numeric)
Others can be done with string processing as illustrated above with the
date. You might also need to discard the date portion of the date-time
string and keep just the time:
.time := \fword(\m(time),2,\32,:)
- Frank